{% extends 'car/base.html' %}

{% block content %}
<div class="card">
    <div class="card-header">{{ object.name }}</div>
    <div class="card-body">
        <table class="table table-striped">
            <tr>
                <th>Начало</th>
                <th>Окончание</th>
                <th>Владелец</th>
            </tr>
            {% for history_item in object.carhistory_set.all %}
            <tr>
                <td>{{ history_item.start_year }}</td>
                <td>
                    {% if history_item.stop_year %}
                        {{ history_item.stop_year }}
                    {% else %}
                        по настоящее время
                    {% endif %}
                </td>
                <td>
                    {% if history_item.owner %}
                        {{ history_item.owner }}
                    {% else %}
                        не указан
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        </table>
    </div>
    <div class="card-footer">
        {% if user.car.add_car %}
        <a href="{% url 'order:create' object.pk %}" class="btn btn-outline-success">Составить заявку</a>
        {% endif %}
    </div>
</div>
{% endblock %}